import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:wanxiang_app/utils/common.dart';
import 'package:wanxiang_app/utils/toast_util.dart';
import 'package:wanxiang_app/widgets/tabs.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../bean/merchant_entity.dart';
import 'account_textField2.dart';
typedef void ClickCallBack(String content);
class MerchantDialog extends Dialog {
  ClickCallBack callBack;
   MerchantData? merchantEntity;
  MerchantDialog({this.merchantEntity, required this.callBack});

  @override
  Widget build(BuildContext context) {
    return Material(
        //透明层
        type: MaterialType.transparency,
        child: Stack(
          children: <Widget>[
            Positioned(
                bottom: 0,
                child:
                Container(
                  height: 409.h,
                  width: MediaQuery.of(context).size.width,
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.only(topRight: Radius.circular(20.r),topLeft: Radius.circular(20.r))
                  ),
                  child: Column(
                    children: [
                      SizedBox(height: 10.h,),
                      Text('号商：'+merchantEntity!.name,style: TextStyle(color: Color(0xFF333333),fontSize: 17.sp,fontWeight: FontWeight.bold),),
                      SizedBox(height: 18.h,),
                      GestureDetector(
                        onLongPress: () {
                          print("长按事件 ");
                          var str = merchantEntity!.codeUrl;
                          str=str.replaceAll("http://p.taohaoge.com/", '');
                          print(str);
                          Common.saveNetworkImage(merchantEntity!.codeUrl);
                        },
                        child:   Image.network(merchantEntity!.codeUrl,width: 204.w,height: 204.w,),
                      ),

                      SizedBox(height: 18.h,),

                      Text('长按图片可保存本地',style: TextStyle(color: Color(0xFF6C6C6C),fontSize: 12.sp),),
                      SizedBox(height: 18.h,),
                      Text('联系方式：${merchantEntity!.isQq==1?merchantEntity!.qqNum:merchantEntity!.wxNum}',style: TextStyle(color: Color(0xFF333333),fontSize: 12.sp,fontWeight: FontWeight.bold),),
                      InkWell(
                        onTap: (){
                          Clipboard.setData(ClipboardData(text: merchantEntity!.isQq==1?merchantEntity!.qqNum:merchantEntity!.wxNum));
                          ToastUtil.show("已复制");
                        },
                        child: Container(
                          margin: EdgeInsets.only(top: 18.h),
                          width: 246.w,
                          height: 35.h,
                          alignment: Alignment.center,
                          decoration: BoxDecoration(
                              color: Color(0xFF017AE3),
                              borderRadius: BorderRadius.circular(18.r)
                          ),
                          child: Text('复制号码',style:TextStyle(
                              color: Colors.white,
                              fontSize: 11.sp
                          ),),
                        )
                      )

                    ],
                  )
                )

             ),
            Positioned(
                bottom: 370.h,
                child:  IconButton(onPressed: (){
                  callBack("close");
                }, icon:Icon(Icons.close,size: 28,), ))

            

          ],
        )
    );
  }
}